home *** CD-ROM | disk | FTP | other *** search
- class XMLConstruct extends XMLConstructNode
- {
- var XMLEventDispatcher;
- var attributes;
- var rootVal = "firstChild";
- function XMLConstruct(input)
- {
- super();
- this.XMLEventDispatcher = new mx.events.EventDispatcher();
- if(input != undefined)
- {
- this.parse(input);
- }
- }
- function addEventListener(event, listener)
- {
- this.XMLEventDispatcher.addEventListener(event,listener);
- }
- function removeEventListener(event, listener)
- {
- this.XMLEventDispatcher.removeEventListener(event,listener);
- }
- function get stripRoot()
- {
- if(this.rootVal eq "firstChild")
- {
- return true;
- }
- return false;
- }
- function set stripRoot(z)
- {
- if(z eq true)
- {
- this.rootVal = "firstChild";
- }
- else
- {
- this.rootVal = undefined;
- }
- }
- function parse(input)
- {
- var _loc7_ = undefined;
- var _loc3_ = undefined;
- var _loc2_ = undefined;
- var _loc4_ = undefined;
- _loc3_ = this.parseNode(input[this.rootVal],new XMLConstructNode());
- for(_loc2_ in this)
- {
- if(this[_loc2_] instanceof Array)
- {
- delete this[_loc2_];
- }
- }
- this.attributes = undefined;
- _loc4_ = [];
- for(_loc2_ in _loc3_)
- {
- if(_loc2_ eq "attributes")
- {
- for(var _loc5_ in _loc3_[_loc2_])
- {
- this.addAttribute(_loc5_,_loc3_[_loc2_][_loc5_]);
- }
- }
- else
- {
- _loc4_.push(_loc2_);
- }
- }
- for(_loc2_ in _loc4_)
- {
- this[_loc4_[_loc2_]] = _loc3_[_loc4_[_loc2_]];
- }
- }
- function parseNode(xObj, obj)
- {
- var _loc2_ = undefined;
- var _loc5_ = undefined;
- var _loc4_ = undefined;
- var _loc3_ = undefined;
- var _loc8_ = xObj.attributes;
- for(_loc2_ in _loc8_)
- {
- obj.addAttribute(_loc2_,_loc8_[_loc2_]);
- }
- for(_loc2_ in xObj.childNodes)
- {
- _loc3_ = xObj.childNodes[_loc2_];
- _loc5_ = _loc3_.nodeName;
- _loc4_ = _loc3_.nodeType;
- if(_loc4_ == 3)
- {
- obj._value = _loc3_.nodeValue;
- }
- else if(_loc4_ == 1 && _loc5_ != null)
- {
- var _loc7_ = this.parseNode(_loc3_,new XMLConstructNode());
- obj.appendChild(_loc5_,_loc7_);
- }
- }
- return obj;
- }
- function load(file)
- {
- var thisObj = this;
- var tXML = new XML();
- tXML.ignoreWhite = true;
- tXML.load(file);
- tXML.onLoad = function(success)
- {
- thisObj.parse(tXML);
- thisObj.onLoad(success);
- thisObj.XMLEventDispatcher.dispatchEvent({type:"onLoad",target:thisObj,success:success});
- };
- }
- }
-